package com.yanqu.road.server.manger.assistant.handler;

import com.yanqu.road.pb.assistant.AssistantProto;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.assistant.AssistantMgr;
import com.yanqu.road.server.manger.assistant.CrossActionHandler;

/**
 * 小助手押镖跨服处理
 *
 * @author hgd
 */
public class EscortCrossActionHandler extends CrossActionHandler {

    public EscortCrossActionHandler() {
        this.success = false;
    }

    @Override
    protected void action(GamePlayer player, AssistantProto.AssistantActionReqMsg.Builder reqMsg, AssistantProto.AssistantActionRespMsg.Builder respMsg) {
        if (AssistantMgr.includeEscortAction(reqMsg.getOperateEnumList())) {
            AssistantProto.AssistantBeautyEscortCartRespMsg.Builder beautyEscortCartRespMsg = AssistantProto.AssistantBeautyEscortCartRespMsg.newBuilder();
            int ret = AssistantMgr.escortAction(player, reqMsg, respMsg);
            if (ret != 0) {
                beautyEscortCartRespMsg.setRet(ret);
                respMsg.setAssistantBeautyEscortCartRespMsg(beautyEscortCartRespMsg);
            } else {
                success = true;
            }
        }
    }

    @Override
    protected void nextHandler(GamePlayer player, AssistantProto.AssistantActionReqMsg.Builder reqMsg, AssistantProto.AssistantActionRespMsg.Builder respMsg) {
        new ZsCrossActionHandler().handle(player, reqMsg, respMsg);
    }
}
